/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package db;

/**
 *
 * @author demian
 */
import java.sql.*;


public class ConexionDB {
	public static String bd = "sudokuTOP10_db";
	private static String login = "root";
	private static String password = "root";
	private static String url = "jdbc:mysql://localhost/"+bd;
	private static ConexionDB instance;
	private static Connection conn;
	
	public synchronized static Connection getInstance(){
		if (instance == null)
			instance = new ConexionDB();
		return conn;
	}

	public ConexionDB() {
	      try{
	         Class.forName("com.mysql.jdbc.Driver");
	         conn = (Connection) DriverManager.getConnection(url, login, password);
	         if (conn!=null){
	            System.out.println("Base de datos " + bd + " conectada");
	         }
	      }catch(Exception ex){
	    	  ex.printStackTrace();
	      }
	   }

	public void closeConnection(){
	    conn = null;
	}
}